import React, { Component } from "react";
import { Outlet } from "react-router-dom";
import { connect } from "react-redux";
import { Navigate } from "react-router-dom";
import { createDeleteUserInfoAction } from "../../redux/action_creators/login_action";
import { Layout } from "antd";
import "./index.scss";
import Header from "./header";
import LeftMenu from "./left_nav";
const { Footer, Sider, Content } = Layout;
@connect((state) => ({ userInfo: state.userInfo }), {
  deleteUserInfo: createDeleteUserInfoAction,
})
class Admin extends Component {
  logout = () => {
    this.props.deleteUserInfo();
  };
  render() {
    const { isLogin } = this.props.userInfo;
    return (
      <div className="admin">
        {!isLogin && <Navigate to="/login" replace="true" />}
        <Layout className="layout">
          <Sider>
            <LeftMenu />
          </Sider>
          <Layout>
            <Header>Header</Header>
            <Content className="content">
              <Outlet />
            </Content>
            <Footer>Footer</Footer>
          </Layout>
        </Layout>
      </div>
    );
  }
}

export default Admin;
